package com.zmn.oms.business.impl.es;

import com.zmn.base.oms.common.model.es.orderwork.EsOrderWork;
import com.zmn.oms.business.interfaces.es.OrderWorkEsBService;
import com.zmn.oms.services.interfaces.es.OrderWorkESearchService;
import org.elasticsearch.search.aggregations.Aggregations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类描述：
 *
 * @author wangxiaokun
 * @since 2022/05/23 15:18
 */
@Service
public class OrderWorkEsBServiceImpl implements OrderWorkEsBService {

    @Autowired
    OrderWorkESearchService orderWorkESearchService;

    @Override
    public Aggregations getAggregationsByQuery(NativeSearchQuery nativeSearchQuery) {
        nativeSearchQuery.setTrackTotalHits(true);
        return orderWorkESearchService.getAggregationsByQuery(nativeSearchQuery);
    }

    @Override
    public EsOrderWork getEsOrderWorkById(Long id) {
        return orderWorkESearchService.getEsOrderWorkById(id);
    }

    @Override
    public List<EsOrderWork> listPageByQuery(NativeSearchQuery nativeSearchQuery) {
        nativeSearchQuery.setTrackTotalHits(true);
        return orderWorkESearchService.listPageByQuery(nativeSearchQuery);
    }

    @Override
    public Long countByQuery(NativeSearchQuery nativeSearchQuery) {
        return orderWorkESearchService.countByQuery(nativeSearchQuery);
    }
}
